package vn.sunnet.game.SinhTon.object;

import vn.sunnet.game.SinhTon.global.Assets;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

// Con boss nay di ra sau do se ban
public class Boss10 extends Boss {
	float stateTime;
	private float timeDie;
	private Rectangle boundsLeft;
	private Animation aniLeftNipper;
	private float timeDelay;

	public Boss10() {
		setAnimation(Assets.atBoss10);
		setScore(50);
		switch (Assets.map) {
		case 1:
			setHp(800);
			setDamageSpeed(800);
			setBounds(new Rectangle(108, 520, 144, 160));
			setVelocity(new Vector2(0, 40));
			break;
		case 3:
			setHp(850);
			setDamageSpeed(950);
			setBounds(new Rectangle(308, 520, 144, 160));
			setVelocity(new Vector2(0, 50));
			break;
		case 5:
			setHp(1100);
			setDamageSpeed(1100);
			setBounds(new Rectangle(538, 520, 144, 160));
			setVelocity(new Vector2(0, 60));
			break;
		case 7:
			setHp(1250);
			setDamageSpeed(1250);
			setBounds(new Rectangle(328, 520, 144, 160));
			setVelocity(new Vector2(0, 70));
			break;
		case 9:
			setHp(1400);
			setDamageSpeed(1400);
			setBounds(new Rectangle(208, 520, 144, 160));
			setVelocity(new Vector2(0, 80));
			break;
		default:
			break;
		}

		boundsLeft = new Rectangle(getBounds().x - 30, getBounds().x - 40, 103,
				100);
		aniLeftNipper = Assets.atNipperLeft;

	}

	@Override
	void move(float time, int speed) {
		// di chuyen
		if (getBounds().y > 200) {
			getBounds().y -= time * getVelocity().y * speed ;
//			switch (Assets.map) {
//			case 1:
//				getBounds().y -= time * getVelocity().y * speed ;
//				break;
//			case 3:
//				getBounds().y -= time * getVelocity().y * speed;
//				break;
//			case 5:
//				getBounds().y -= time * getVelocity().y * speed;
//				break;
//			case 7:
//				getBounds().y -= time * getVelocity().y * speed;
//				break;
//			case 9:
//				getBounds().y -= time * getVelocity().y * speed;
//				break;
//			default:
//				break;
//			}
			
		} else {
			setState_Boss(1);
		}
	}

	@Override
	public void shot(int dame) {
		float hp = getHp() - 2 * dame;
		setHp(hp);
		if (getHp() <= 0) {
			setState_Boss(2);
		}
	}

	public TextureRegion getTextureLeft() {
		return aniLeftNipper.getKeyFrame(stateTime, true);
	}

	@Override
	public TextureRegion getTexture() {
		return getAnimation().getKeyFrame(stateTime, true);
	}

	public void update(float time, int speed) {
		stateTime += 0.5 * time;
		timeDelay += time;
		switch (getState_Boss()) {
		case 0:
			if (timeDelay > 2)
				move(time, speed);
			else

				break;

		case 1:

			break;
		case 2:
			timeDie += 0.5f * time;
			// Cho thoi gian chet cua Zombie laf 0.7
			if (timeDie > 0.7) {
				// Sau 0.7s tu luc chet thi se xoa zombie
				setState_Boss(3);
			}
		case 3:
			// Gdx.app.log("", "message");
			break;
		}
	}

	public Rectangle getBoundsLeft() {
		return boundsLeft;
	}
}
